package TestDemo;

class Singleton {
    private static Singleton singleton = new Singleton();

    public static Singleton getSingleton() {
        return singleton;
    }

    private Singleton() {

    }
}

class SingletonLazy {
    private static SingletonLazy singletonLazy = null; // 类加载时不创建实例

    private SingletonLazy() {

    }

    public static SingletonLazy getSingletonLazy() {
        if (singletonLazy == null) {
            synchronized (SingletonLazy.class) {
                if (singletonLazy == null) {
                    singletonLazy = new SingletonLazy(); // 第一次调用get函数时才创造实例
                }
            }
        }
        return singletonLazy;
    }
}

public class TestDemo1 {

}
